namespace PickGold.Charting
{
	using System;
	using System.ComponentModel;
	using System.Drawing;
	using System.Globalization;
	using System.Security.Permissions;
	using System.Web;

	[TypeConverter(typeof(MarginExpandableObjectConverter)), SRDescription("DescriptionAttributeMargins_Margins"), AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	public class Margins
	{
		private int _bottom;
		private int _left;
		private int _right;
		private int _top;

		public Margins()
		{
		}

		public Margins(int top, int bottom, int left, int right)
		{
			this._top = top;
			this._bottom = bottom;
			this._left = left;
			this._right = right;
		}

		public override bool Equals(object obj)
		{
			Margins margins = obj as Margins;
			return ((((margins != null) && (this.Top == margins.Top)) && ((this.Bottom == margins.Bottom) && (this.Left == margins.Left))) && (this.Right == margins.Right));
		}

		public override int GetHashCode()
		{
			return (((this.Top.GetHashCode() + this.Bottom.GetHashCode()) + this.Left.GetHashCode()) + this.Right.GetHashCode());
		}

		private void Invalidate()
		{
		}

		public bool IsEmpty()
		{
			return ((((this.Top == 0) && (this.Bottom == 0)) && (this.Left == 0)) && (this.Right == 0));
		}

		public RectangleF ToRectangleF()
		{
			return new RectangleF((float)this.Left, (float)this.Top, (float)this.Right, (float)this.Bottom);
		}

		public override string ToString()
		{
			return string.Format(CultureInfo.InvariantCulture, "{0:D}, {1:D}, {2:D}, {3:D}", new object[] { this.Top, this.Bottom, this.Left, this.Right });
		}

		[SRCategory("CategoryAttributeMisc"), RefreshProperties(RefreshProperties.All), NotifyParentProperty(true), DefaultValue(0), SRDescription("DescriptionAttributeMargins_Bottom")]
		public int Bottom
		{
			get
			{
				return this._bottom;
			}
			set
			{
				if (value < 0)
				{
					throw new ArgumentException(SR.ExceptionMarginBottomIsNegative, "value");
				}
				this._bottom = value;
				this.Invalidate();
			}
		}

		[SRCategory("CategoryAttributeMisc"), DefaultValue(0), RefreshProperties(RefreshProperties.All), SRDescription("DescriptionAttributeMargins_Left"), NotifyParentProperty(true)]
		public int Left
		{
			get
			{
				return this._left;
			}
			set
			{
				if (value < 0)
				{
					throw new ArgumentException(SR.ExceptionMarginLeftIsNegative, "value");
				}
				this._left = value;
				this.Invalidate();
			}
		}

		[NotifyParentProperty(true), DefaultValue(0), RefreshProperties(RefreshProperties.All), SRCategory("CategoryAttributeMisc"), SRDescription("DescriptionAttributeMargins_Right")]
		public int Right
		{
			get
			{
				return this._right;
			}
			set
			{
				if (value < 0)
				{
					throw new ArgumentException(SR.ExceptionMarginRightIsNegative, "value");
				}
				this._right = value;
				this.Invalidate();
			}
		}

		[RefreshProperties(RefreshProperties.All), SRDescription("DescriptionAttributeMargins_Top"), NotifyParentProperty(true), SRCategory("CategoryAttributeMisc"), DefaultValue(0)]
		public int Top
		{
			get
			{
				return this._top;
			}
			set
			{
				if (value < 0)
				{
					throw new ArgumentException(SR.ExceptionMarginTopIsNegative, "value");
				}
				this._top = value;
				this.Invalidate();
			}
		}
	}
}

